package data.groovy

import com.alibaba.fastjson.JSONObject
import com.lgy.httpmocktool.config.DataBaseConfig
import groovy.sql.Sql

def execute(JSONObject reqBody){
        JSONObject respBody = new JSONObject();
        JSONObject head = reqBody.get("head");
        String id = head.getString("id");
        String key = reqBody.getString("key");
        def sql = Sql.newInstance(DataBaseConfig.getDbUrl(), DataBaseConfig.getDriverName());
        sql.eachRow("select * from groovy_resp_json where resp_group = ${id}") {
                println("resp_key = ${it.resp_key}, resp_group= ${it.resp_group}")
                if (key.equals(it.resp_key)) {
                        println("resp_key = ${it.resp_key}")
                        respBody = JSONObject.parse(it.resp_value);
                }
        }
        return respBody;
}


